print("四个不同方向的直角三角形")
print("=" * 50)

# 获取用户输入的边长（不使用函数）
while True:
    try:
        side_length = int(input("请输入三角形的边长: "))
        if side_length > 0:
            break
        else:
            print("边长必须为正整数，请重新输入。")
    except ValueError:
        print("请输入有效的整数。")

print("\n1. 向右上的直角三角形:")
i = 1
while i <= side_length:
    j = 1
    while j <= i:
        print("*", end="")
        j += 1
    print()  # 换行
    i += 1

print("\n2. 向左上的直角三角形:")
i = 1
while i <= side_length:
    # 打印空格
    j = 1
    while j <= side_length - i:
        print(" ", end="")
        j += 1
    # 打印星号
    k = 1
    while k <= i:
        print("*", end="")
        k += 1
    print()  # 换行
    i += 1

print("\n3. 向右下的直角三角形:")
i = side_length
i = side_length
while i >= 1:
    j = 1
    while j <= i:
        print("*", end="")
        j += 1
    print()  # 换行
    i -= 1

print("\n4. 向左下的直角三角形:")
i = side_length
i = side_length
while i >= 1:
    # 打印空格
    j = 1
    while j <= side_length - i:
        print(" ", end="")
        j += 1
    # 打印星号
    k = 1
    while k <= i:
        print("*", end="")
        k += 1
    print()  # 换行
    i -= 1

print("\n" + "=" * 50)
print("四个方向的直角三角形已全部显示完毕")